class TG_Camera extends Camera;

var const TG_CameraProperties CameraProperties;

function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
  local Pawn Pawn;
  local Vector V, PotentialCameraLocation;
  
  /** UpdateViewTarget for the camera class we're extending from */
  Super.UpdateViewTarget(OutVT, DeltaTime);

  /** If there is an interpolation, don't update outgoing viewtarget */
  if (PendingViewTarget.Target!=None&&OutVT==ViewTarget&&BlendParams.bLockOutgoing)
  {
    return;
  }

  Pawn = Pawn(OutVT.Target);
  if (Pawn != None)
  {
      if(Pawn.Mesh.GetSocketWorldLocationAndRotation('Waist', OutVT.POV.Location, OutVT.POV.Rotation)==false) 
    {
      /** Start the cam location from the target eye view point */
      OutVT.Target.GetActorEyesViewPoint(OutVT.POV.Location, OutVT.POV.Rotation);
    }

    /** Force the camera to use the target's rotation */
    OutVT.Target.GetActorEyesViewPoint(V, OutVT.POV.Rotation);

    /** Add the camera offset */
    OutVT.POV.Rotation = CameraProperties.CameraRotationOffset;

    /** Math for the potential camera location */
    PotentialCameraLocation = OutVT.POV.Location + (CameraProperties.CameraOffset >> OutVT.POV.Rotation);     

      OutVT.POV.Location=PotentialCameraLocation;
  }
}

defaultproperties
{
    CameraProperties=TG_CameraProperties'TG_Content.Archetype.CameraProperties'
}